/*
 * @Author: your name
 * @Date: 2020-10-25 12:10:55
 * @LastEditTime: 2021-01-13 13:46:57
 * @LastEditors: your name
 * @Description: In User Settings Edit
 * @FilePath: /undefined/home/messi/Data_Structure_and_Algorithm_GIT/SORT/Heap/heap.h
 */
// An implementation of Heapsort.

#ifndef __hhxxttxs_HEAP__
#define __hhxxttxs_HEAP__

class heap {
private:
    int *data;
    int length;
public:
#define PARENT(i) ((((i)+1) >> 1) - 1)
#define LEFTCHILD(i) ((((i)+1) << 1) - 1)
#define RIGHTCHILD(i) (((i)+1) << 1)
    int get_length();
    int get_height();
    Heap(int *datahead, int l);
    ~Heap();
    //check if the heap is empty
    //if not, clear it
    bool is_empty();
    int printout();
    int sort();
    int shiftdown(int i);
    //shiftdown the i-th node to recover the properites of min-heap. 
};

#else
//DO NOTHING!
#endif